<?php

namespace asyncService;

use asyncService\message\interfaceMessage;

abstract class Factory
{
    static function getConfigKey(){
        return __CLASS__;
    }

    static function getConfig(){
        return Bootstrap::$instance->getConfig(static::getConfigKey());
    }

    /**
     * @param bool $config
     * @return interfaceMessage
     */
    static function Produce($config = false){
        if($config === false){
            $config = self::getConfig();
        }
        if(is_string($config)){
            $class  = $config;
        }else{
            $class  = $config['class'];
        }

        $Object = new $class($config);
        return $Object;
    }
}